package MONITORING::DB::MYSQL::ERROR_LOG;

#################################################################
# $LastChangedDate: 2013-11-25 15:03:06 +0000 (Mon, 25 Nov 2013) $
# $LastChangedRevision: 22 $
# $LastChangedBy: aswod_83@gmx.net $
#################################################################
use strict;
use base qw(moniCA::DBH::MySQL);
use XML::Simple;
use Data::Dumper;

#-------------------------------------------------------------------------------
sub Run {

#-------------------------------------------------------------------------------
# Description:
# Input Parms:
# Output Parms:
#-------------------------------------------------------------------------------
    my $self      = shift;
    my $cnf       = $self->GetCNF();
    my $logger    = $self->GetLogger();
    my $statefile = $self->TmpDir() . '/' . $self->Plug() . '.xml';

    $self->find_err( $self->_getVAR_log_error() );
}

#-------------------------------------------------------------------------------
sub _getVAR_log_error {

#-------------------------------------------------------------------------------
# Description:
# Input Parms:
# Output Parms:
#-------------------------------------------------------------------------------
    my $self = shift;
    $self->ConnectDB();
    my $stmt = q{
						show variables where Variable_name ='log_error'
					};
    my $sth = $self->{DBH}->prepare($stmt);
    $sth->execute();
    my $row    = $sth->fetchrow_arrayref();
    my $string = $$row[1];
    $sth->finish();
    $self->DisconnectDB();
    return $string;
}

1;
__END__
 
=pod
 
=head1 NAME
 
ERROR_LOG.pm - monitors mysql error log 
 
=head1 SYNOPSIS 
 
=head1 DESCRIPTION
 
=head1 PREREQUISITES
 
The follwing modules needs to be installed:
 
C<Log::Log4perl>
C<XML::Simple>
C<base qw(moniCA::DBH::MySQL)>
 
=head1 CONFIGURATION FILE
 
  By default
 
=head2 EXAMPLES
 
=head3 example of configuation file

Modul 	    MONITORING::DB::MYSQL::ERROR_LOG
Logger		tbs-xe
LogLevel	DEBUG

<DBConnect>
	ConnectString	dbi:mysql:database=test;host=127.0.0.1;port=3306
	dbuser		monica
	dbpw		monica
	description 	TEST DB
</DBConnect>

<blacklist>
BL1	= error
</blacklist>

<whitelist>
WL1 = 	(Got an error reading communication packets)
WL2 = Error reading packet from server: Lost connection to MySQL server during query
</whitelist>

=cut
